package com.xue.utils;
import java.util.Random;

/**
 * @author xue
 * @ClassName: RandomUtils
 * @Date: Created in 11:31 2021/10/31
 * @Description:
 */
public class RandomUtils {

    public static String randomPhone() {
        String phonePrefix = "133";
        Random random = new Random();
        for (int i = 0; i < 8; i++) {
            int num = random.nextInt(9);
            phonePrefix = String.format("%s%d", phonePrefix, num);
        }
        return phonePrefix;
    }

    public static String getUnRegisterPhone() {
        String phone = "";
        while (true) {
            phone = randomPhone();
            long result = (long)JdbcUtils.queryValue("select count(*) from member where mobile_phone = '" + phone + "' ;");
            if (result == 0) {
                break;
            }
        }
        return phone;
    }
}
